#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <poll.h>

int main(int argc,char **argv)
{
    int fd;
    if((fd = open("/dev/input/mouse0",O_RDWR|O_CREAT,0655))<0)
    {
        perror("open file error");
        exit(1);
    }
    struct pollfd fds[2];
    fds[0].fd=0;
    fds[0].events=POLLIN;
    fds[1].fd=fd;
    fds[1].events=POLLIN;
    while(1){
    int ret=poll(fds,2,3000);
    for(int i=0;i<2;i++)
    {
        if(fds[i].events==fds[i].revents)
        {
            if(fds[i].fd==0)
            {
                char buff[1024];
                read(fds[i].fd,buff,sizeof(buff));
                printf("%s",buff);
            }
            else if(fds[i].fd==fd)
            {
                int cor;
                read(fds[i].fd,&cor,sizeof(cor));
                printf("cor=%d\n",cor);
            }
            if(--ret == 0)
            {
                break;
            }
        }
    }
    }

}